// 在javascript来优化上一节传统面向对象写法的操作，可以使用对象进行简化

var strategies = {
    "S" : function(salary) {
        return salary * 4
    },
    "A" : function(salary) {
        return salary * 3
    },
    "B" : function(salary) {
        return salary * 2
    },
}

var calculateBonus = function (salary , strategy) {
    return strategies[strategy](salary)
}

console.log(calculateBonus(400,"S"));
console.log(calculateBonus(400,"A"));
console.log(calculateBonus(400,"B"));
